package Object_Class;

public class MyDate {
	
	private int year;
	private int month;
	private int day;
	private String[] strMonths={"Jan","Feb","Mar","Apr","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
	private String[] strDays={"Sunday","Monday","TuesDay","Wednesday","Thursday","Frida","Saturday"};
	private int[] daysInMonths={31,28,31,30,31,30,31,31,30,31,30,31};
	
	public boolean isLeapYear(int year){
		if((year%4==0 && year%400==0)&&year%100!=0){
			return true;
		}
		return false;
	}
	public boolean isValidDate(int year,int month,int day){
		return false;
		
	}
	public int getDayOfWeek(int year ,int month,int day){
		return day;
	}
	public MyDate(int year ,int month,int day){
		this.day=day;
		this.month=month;
		this.year=year;
	}
	public void setDate(int year,int month,int day){
		
	}

	public int getYear() {
		return year;
	}
	public void setYear(int year) {
		this.year = year;
	}
	public int getMonth() {
		return month;
	}
	public void setMonth(int month) {
		this.month = month;
	}
	public int getDay() {
		return day;
	}
	public void setDay(int day) {
		this.day = day;
	}
	
	@Override
	public String toString() {
		return "MyDate [year=" + year + ", month=" + month + ", day=" + day + "]";
	}
	
	public MyDate nextDay(){
		day++;
		int maxM=daysInMonths[month-1];
		if(isLeapYear(year)&&month==2){
			maxM=maxM+1;
		}
		if(day>maxM){
			month++;
			day=1;
		}
		if(month==13){
			year++;
			month=1;
		}
		return this;
	}
	public MyDate nextMonth(){
		month++;
		if(month==13){
			year++;
		}
		return this;
	}
	public MyDate nextYear(){
		year++;
		return this;
	}
	
	
	public MyDate previousDay(){
		
		return this;
	}
	public MyDate previousMonth(){
		return this;
	}
	public MyDate previousYear(){
		return this;
	}
	public static void main(String[] args) {
		MyDate md = new MyDate(2000,2,29);
		System.out.println(md.toString());
	}
}


//public class MyDate {
//	private int year;
//	private int month;
//	private int day;
//	private String[] strMonths={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sup","Oct","Nov","Dec"};
//	private String[] strDays={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
//	private int[] daysInMonths={31,28,31,30,31,30,31,31,30,31,30,31};
//	public boolean isLeapYear(int year){
//		if(year%4==0&&year%100!=0||year%400==0){
//			return true;
//		}else return false;
//	}
//	public boolean isValidDate(int year,int month,int day){
//		if(isLeapYear(year)&&month==2&&day==29)return true;
//		if(month>=1&&month<=12){
//			if(day>=1&&day<=daysInMonths[month-1]){
//				return true;
//			}
//		}return false;
//	}
//	public int getDayOfWeek(int year,int month,int day){
//		int a;
//		int b=0;
//		int c=0;
//		for(int i=1970;i<year;i++){
//			if(isLeapYear(i)){
//				b++;
//			}
//		}
//		for(int i=0;i<month-1;i++){
//			c=c+daysInMonths[i];
//		}
//		if(isLeapYear(year)&&month>2){
//			c++;
//		}
//		a=(year-1970)*365+b+c+day;
//		return a%7+3;
//	}
//	public MyDate() {
//		
//	}
//	public MyDate(int year, int month, int day) {
//		super();
//		this.year = year;
//		this.month = month;
//		this.day = day;
//	}
//	public int getYear() {
//		return year;
//	}
//	public int getMonth() {
//		return month;
//	}
//	public int getDay() {
//		return day;
//	}
//	public void setYear(int year) {
//		this.year = year;
//	}
//	public void setMouth(int month) {
//		this.month = month;
//	}
//	public void setDay(int day) {
//		this.day = day;
//	}
//	@Override
//	public String toString() {
//		return "MyDate [year=" + year + ", month=" + month + ", day=" + day + "]";
//	}
//	public MyDate nextDay(){
////		if(day==28&&month==2&&isLeapYear(year)){
////			this.day=29;
////			this.month=2;
////			return this;
////		}
//		this.day++;
//		
//		if(!isValidDate(this.year,this.month,this.day)){
//			month++;
//			this.day=1;
//			
//		}
//		if(!isValidDate(this.year,this.month,this.day)){
//			year++;
//			this.month=1;
//		}
//		
//		return this;
//	}
//	public MyDate nextMonth(){
//		this.month++;
//		if(!isValidDate(this.year,this.month,this.day)){
//			year++;
//			this.month=1;
//		}
//		return this;
//	}
//	public MyDate nextYear(){
//		this.year++;
//		return this;
//	}
//	public MyDate previousDay1(){
//		this.day--;
//		if(!isValidDate(this.year,this.month,this.day)){
//			month--;
//			if((isLeapYear(year)&&month==2&&day==0)){
//				this.day=29;
//			}
//			else{
//				if(month ==0 ){
//					month=12;
//					year--;
//				}
//				this.day=daysInMonths[month -1];
//			}
//		}
//		return this;
//	}
//	public MyDate previousMonth(){
//		this.month--;
//		if(!isValidDate(this.year,this.month,this.day)){
//			year--;
//			this.month=12;
//		}
//		return this;
//	}
//	public MyDate previousYear(){
//		this.year--;
//		return this;
//	}
//	public class MyDateTest {
//public static void main(String[] args) {
//	MyDate md=new MyDate(2004,2,29);
//	System.out.println(md.getDayOfWeek(2016, 12, 31));
//	System.out.println(md.toString());
//	System.out.println(md.previousDay());
//}
//}
//
//}
